﻿namespace Maple.Weixin.MP.Entities.JsonResult
{
    public class UserInfoResult : WeixinServiceResult
    {
        public string openid { get; set; }
        public string nickname { get; set; }
        public string sex { get; set; }
        public string province { get; set; }
        public string city { get; set; }
        public string country { get; set; }
        public string headimgurl { get; set; }
        public string[] privilege { get; set; }
    }

    public sealed class HeadImage
    {
        private string imageUrl;

        public HeadImage(string imageUrl)
        {
            this.imageUrl = imageUrl;
        }

        public HeadImage Resize(HeadImageSize size)
        {
            if (!string.IsNullOrEmpty(imageUrl))
            {
                var startIndex = imageUrl.LastIndexOf('/');
                var strTemp = imageUrl.Substring(0, startIndex);
                var newUrl = strTemp + size;
                this.imageUrl = newUrl;
            }
            return this;
        }

        public string ImageUrl
        {
            get { return imageUrl; }
        }
    }

    public enum HeadImageSize
    {
        /// <summary>
        /// 640*640
        /// </summary>
        Larger = 0,

        /// <summary>
        /// 132*132
        /// </summary>
        Large = 132,

        /// <summary>
        /// 96*96
        /// </summary>
        Normal = 96,

        /// <summary>
        /// 64*64
        /// </summary>
        Small = 64,

        /// <summary>
        /// 46*46
        /// </summary>
        Smaller = 46,
    }
}

